/**
 * 空间用户关联API接口
 */
import { apiClient } from './config'
import type {
  SpaceUserVO,
  SpaceUser,
  SpaceUserAddRequest,
  SpaceUserEditRequest,
  SpaceUserQueryRequest,
  DeleteRequest,
} from '@/types/space-user'
import type { ApiResponse } from '@/types/common'

// 查询成员加入的团队空间列表
export const listMyTeamSpaces = () => {
  return apiClient.post<ApiResponse<SpaceUserVO[]>>('/spaceUser/list/my')
}

// 查询团队空间内的所有成员
export const listSpaceUser = (params: SpaceUserQueryRequest) => {
  return apiClient.post<ApiResponse<SpaceUserVO[]>>('/spaceUser/list', params)
}

// 查询成员在指定空间的信息
export const getSpaceUser = (params: SpaceUserQueryRequest) => {
  return apiClient.post<ApiResponse<SpaceUser>>('/spaceUser/get', params)
}

// 添加空间用户
export const addSpaceUser = (params: SpaceUserAddRequest) => {
  return apiClient.post<ApiResponse<boolean>>('/spaceUser/add', params)
}

// 更新空间用户信息
export const editSpaceUser = (params: SpaceUserEditRequest) => {
  return apiClient.post<ApiResponse<boolean>>('/spaceUser/edit', params)
}

// 删除空间用户
export const deleteSpaceUser = (params: DeleteRequest) => {
  return apiClient.post<ApiResponse<boolean>>('/spaceUser/delete', params)
}
